import Vue from 'vue'
import Router from 'vue-router'
// const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

// /*/////用于第二级时右侧展示区域内容*/
import AppMain from '../views/layout/components/AppMain'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
// export default{
//     fetch() {
//         let that = this;
//         that.axios.get('/activityConsole/activity/console-user/getPrincipal', {
//         }).then(function (res) {
//             console.log(res);
//             const a = res.asd;
//         }).catch(function (error) {
//             console.log(error);
//         })
//     },
// }
export const constantRouterMap = [
    // {
    //   path: '/',
    //   component: Layout,
    //   redirect: '/login',
    //   name: 'login',
    //   hidden: true
    // },
    {
        path: '',
        component: Layout,
        redirect: '/index/index'
    },
    // 首页
    {
        path: '/index',
        name: 'home',
        component: Layout,
        meta: {
            title: 'index',
            icon: 'wel'
        },
        redirect: '/index/index',
        children: [{
            path: 'index',
            name: 'index',
            component: () => import('@/views/index/index'),
            meta: {
                title: 'index',
                icon: 'wel'
            }
        }

        ]
    },
    // 锁屏
    {
        path: '/lock',
        hidden: true,
        name: '锁屏页',
        meta: {
            title: '锁屏页'
        },
        component: () => import('@/views/common/lock')
    },
    {
        path: '/statistics',
        component: Layout,
        redirect: '/statistics/Total',
        name: 'statistics',
        meta: {
            title: 'statistics',
            icon: 'columnar'
        },
        children: [
            {
                path: 'Total',
                name: 'Total',
                component: () => import('@/views/statistics/Total'),
                meta: {
                    title: 'Total',
                    icon: 'scatterChart'
                }
            },
            {
                path: 'Order',
                name: 'Order',
                component: () => import('@/views/statistics/Order'),
                meta: {
                    title: 'Order',
                    icon: 'shoppingCard'
                }
            },
            {
                path: 'DayData',
                name: 'DayData',
                component: () => import('@/views/statistics/DayData'),
                meta: {
                    title: 'DayData'
                },
                hidden: true
            },
            {
                path: 'LuckUser',
                name: 'LuckUser',
                component: () => import('@/views/statistics/LuckUser'),
                meta: {
                    title: 'LuckUser',
                    icon: 'star'
                },
                hidden: false
            },
            {
                path: 'LuckUserGoods',
                name: 'LuckUserGoods',
                component: () => import('@/views/statistics/LuckUserGoods'),
                meta: {
                    title: 'LuckUserGoods',
                    icon: 'star'
                },
                hidden: false
            },
            // 新加留言
            {
                path: 'Message',
                name: 'Message',
                component: () => import('@/views/statistics/Message'),
                meta: {
                    title: 'Message',
                    icon: 'message'
                }
            },
            {
                path: 'Questionnaire',
                name: 'Questionnaire',
                component: () => import('@/views/statistics/Questionnaire'),
                meta: {
                    title: 'Questionnaire',
                    icon: 'edit'
                }
            },
            {
                path: 'Investigation',
                name: 'Investigation',
                component: () => import('@/views/statistics/Investigation'),
                meta: {
                    title: 'Investigation',
                    icon: 'edit'
                }
            }
        ]
    },
    // ////模板编辑
    {
        path: '/template-edit',
        component: Layout,
        redirect: '/template-edit/TemplateIndex',
        name: 'template',
        meta: {
            title: 'template',
            icon: 'table'
        },
        children: [
            //     {
            //   path: 'TemplateIndex',
            //   name: 'TemplateIndex',
            //   component: () => import('@/views/template-edit/TemplateIndex'),
            //   meta: {
            //     title: 'TemplateIndex'
            //   }
            // },
            {
                path: 'ActivityList',
                name: 'ActivityList',
                component: () => import('@/views/template-edit/ActivityList'),
                meta: {
                    title: 'ActivityList',
                    icon: 'list'
                }
            },
            {
                path: 'ActivityDetail',
                name: 'ActivityDetail',
                hidden: true,
                component: () => import('@/views/template-edit/ActivityDetail'),
                meta: {
                    title: 'ActivityDetail'
                }
            },
            {
                path: 'TemplateEdit',
                name: 'TemplateEdit',
                hidden: true,
                component: () => import('@/views/template-edit/TemplateEdit'),
                meta: {
                    title: 'TemplateEdit'
                }
            },
            {
                path: 'PeriodicalEdit',
                name: 'PeriodicalEdit',
                component: () => import('@/views/template-edit/PeriodicalEdit'),
                meta: {
                    title: 'PeriodicalEdit'
                },
                hidden: true
            },
            //   {
            //     path: 'imgSet',
            //     name: 'imgSet',
            //     component: () => import('@/views/components/template-components/imgSet'),
            //     meta: {
            //       title: 'imgSet'
            //     }
            //     hidden: true
            //   },
            {
                path: 'createCoupon',
                name: 'createCoupon',
                component: () => import('@/views/template-edit/createCoupon'),
                meta: {
                    title: 'createCoupon',
                    icon: 'list'
                }
            },
            {
                path: 'CouponList',
                name: 'CouponList',
                component: () => import('@/views/template-edit/CouponList'),
                meta: {
                    title: 'CouponList',
                    icon: 'list'
                }
            },
            {
                path: 'Jurisdiction',
                name: 'Jurisdiction',
                hidden: true,
                component: () => import('@/views/template-edit/Jurisdiction'),
                meta: {
                    title: '权限设置'
                }
            }
        ]
    },
    {
        path: '/periodical',
        component: Layout,
        redirect: '/periodical/PeriodicalMessage',
        name: 'periodical',
        meta: {
            title: 'periodical',
            icon: 'form'
        },
        children: [
            {
                path: 'PeriodicalMessage',
                name: 'PeriodicalMessage',
                component: () => import('@/views/periodical/PeriodicalMessage'),
                meta: {
                    title: 'PeriodicalMessage'
                },
                hidden: false
            }
            // {
            //   path: 'PeriodicalEdit',
            //   name: 'PeriodicalEdit',
            //   component: () => import('@/views/periodical/PeriodicalEdit'),
            //   meta: {
            //     title: 'PeriodicalEdit'
            //   },
            //   hidden: false
            // }
        ]
    },
    {
        path: '/permission',
        component: Layout,
        redirect: '/permission/page',
        name: 'permission',
        meta: {
            title: 'permission',
            icon: 'peoples'
        },
        fetch() {
            const that = this
            that.axios.get('/activityConsole/activity/console-user/getPrincipal', {}).then(function (res) {
                console.log(res)
                const a = res.data.authoritiesStr
            }).catch(function (error) {
                console.log(error)
            })
        },
        children: [
            {
                path: 'directivePermission',
                name: 'directivePermission',
                component: () => import('@/views/permission/directive'),
                meta: {
                    title: 'directivePermission'
                }
            }
        ]
    },
    {
        path: '/messagePost',
        component: Layout,
        redirect: '/messagePost/messagePost',
        name: 'messagePost',
        meta: {
            title: 'messagePost',
            icon: 'email'
        },
        children: [
            {
                path: 'messagePostList',
                name: 'messagePostList',
                component: () => import('@/views/messagePost/list'),
                meta: {
                    title: 'messagePostList',
                    icon: 'list'
                }
            },
            {
                path: 'messagePostData',
                name: 'messagePostData',
                component: () => import('@/views/messagePost/data'),
                meta: {
                    title: 'messagePostData',
                    icon: 'nested'
                }
            },
            {
                path: 'addMessagePost',
                name: 'addMessagePost',
                component: () => import('@/views/messagePost/add'),
                meta: {
                    title: 'addMessagePost',
                },
                hidden: true
            }
        ]
    },
    {
        path: '/login',
        component: () => import('@/views/login'),
        name: '登录admin',
        hidden: true
    },
    {
        path: '/404',
        component: () => import('@/views/errorPage/404'),
        hidden: true
    },
    {
        path: '/401',
        component: () => import('@/views/errorPage/401'),
        hidden: true
    }
    // 图标组件
    /*{
        path: '/iconIndex',
        component: Layout,
        name: 'iconIndex',
        meta: {
            title: 'Icons',
            icon: 'icon'
        },
        children: [
            {
                path: 'iconIndex',
                name: 'iconIndex',
                component: () => import('@/views/svg-icons/iconIndex'),
                meta: {title: 'Icons', icon: 'icon'}
            }
        ]
    },
    // 组件
    {
        path: '/components',
        component: Layout,
        redirect: '/components/dragKanban',
        name: 'Components',
        meta: {
            title: 'Components',
            icon: 'table'
        },
        children: [
            {
                path: '/components/component-two',
                name: 'ComponentTwo',
                component: AppMain,
                redirect: '/components/component-two/two',
                meta: {
                    title: 'ComponentTwo',
                    icon: 'table'
                },
                children: [
                    {
                        path: 'two',
                        name: 'two',
                        component: () => import('@/views/components/component-two/two'),
                        meta: {title: 'two'}
                    },
                    {
                        path: 'three',
                        name: 'three',
                        component: () => import('@/views/components/component-two/three'),
                        meta: {title: 'three'}
                    }
                ]
            },
            {
                path: 'one',
                name: 'one',
                component: () => import('@/views/components/one'),
                meta: {title: 'one'}
            },
            {
                path: 'dragKanban',
                name: 'dragKanban',
                component: () => import('@/views/components/dragKanban'),
                meta: {title: 'dragKanban'}
            },
            {
                path: 'markdown',
                name: 'markdown',
                component: () => import('@/views/components/markdown'),
                meta: {title: 'markdown'}
            },
            {
                path: 'backToTop',
                name: 'backToTop',
                component: () => import('@/views/components/backToTop'),
                meta: {title: 'backToTop'}
            },
            {
                path: 'mixin',
                name: 'componentMixin',
                component: () => import('@/views/components-demo/mixin'),
                meta: {title: 'componentMixin'}
            }
        ]
    }*/
]

export default new Router({
    // mode: 'history', //后端支持可开
    scrollBehavior: () => ({
        y: 0
    }),
    routes: constantRouterMap
})
export const asyncRouterMap = [
    /*{
        path: '/permission',
        component: Layout,
        redirect: '/permission/index',
        alwaysShow: true, // will always show the root menu
        meta: {
            title: 'permission',
            icon: 'lock',
            roles: ['admin', 'editor'] // you can set roles in root nav
        },
        children: [{
            path: 'page',
            component: () => import('@/views/permission/page'),
            name: 'pagePermission',
            meta: {
                title: 'pagePermission',
                roles: ['admin'] // or you can only set roles in sub nav
            }
        }, {
            path: 'directive',
            component: () => import('@/views/permission/directive'),
            name: 'directivePermission',
            meta: {
                title: 'directivePermission'
                // if do not set roles, means: this page does not require permission
            }
        }]
    },
    {
        path: '/error',
        component: Layout,
        redirect: 'noredirect',
        name: 'errorPages',
        meta: {
            title: 'errorPages',
            icon: '404'
        },
        children: [
            {
                path: '401',
                component: () => import('@/views/errorPage/401'),
                name: 'page401',
                meta: {title: 'page401', noCache: true}
            },
            {
                path: '404',
                component: () => import('@/views/errorPage/404'),
                name: 'page404',
                meta: {title: 'page404', noCache: true}
            }
        ]
    },*/
    {
        path: '*',
        redirect: '/404',
        hidden: true
    }
]
